Skip to content

test: tighten unit test assertions across cli, sdk, and mcp#419

Merged
clavery merged 3 commits into
mainfrom
test/audit-fixup-batch1-7
May 13, 2026
Merged

test: tighten unit test assertions across cli, sdk, and mcp#419
clavery merged 3 commits into
mainfrom
test/audit-fixup-batch1-7

Conversation

@clavery
Copy link
Copy Markdown
Collaborator

@clavery clavery commented May 12, 2026

Summary

Resolves the High and Medium findings from the recent unit-test quality audit (PLAN_unit_test_fixup.md). Test-only changes — nothing under any src/ directory was touched.

Test counts

Package Before After
b2c-cli 1218 passing 1224 passing
b2c-tooling-sdk 1722 passing, 6 pending 1717 passing, 0 pending
b2c-dx-mcp 720 passing 720 passing

The SDK net-delta of -5 is +2 substantive tests and +6 previously silently-skipped tests now running, minus 13 tautological smoke tests removed (TypeScript already proved their assertions).

What changed

  • Mock theater removed — webdav buildPath SUT-stubs gone (now observed at the SDK seam); openapi-fetch passthrough tests now assert on Authorization headers, query encoding, and field-level transforms instead of comparing canned data to itself.
  • "displays/logs in non-JSON mode" tests in SCAPI now capture stdout and assert on rendered content rather than stubbing the renderer and checking log.called.
  • Description/assertion mismatches fixed — replication 422/409 distinguishable, sites "no sites" copy verified, content/validate real-validator path tested, job --show-log invocation actually asserted, watcher stop() verifies subsequent file changes are ignored.
  • e2e tests — replaced oneOf([0,1]) and conditional asserts with deterministic checks; code-lifecycle captures the deleted version id before clearing; sandbox-lifecycle delete follows up with a 404 check; AM error tests match real SUT messages; dead hasProject = true skip gate removed.
  • Silent skips made loudMobifySource tests use proper DI in place of Object.defineProperty(os, 'homedir') skip-on-fail; logs integration beforeEach fails loudly under process.env.CI.
  • MCPaddTool tests intercept registerTool and invoke wrapped handlers; site-theming filter verifies the asked question is excluded; page-designer-decorator regex tightened; services tests assert OAuth wiring and base URLs.

Test plan

  • pnpm --filter @salesforce/b2c-cli run test:agent — 1224 passing
  • pnpm --filter @salesforce/b2c-tooling-sdk run test:agent — 1717 passing, 0 pending
  • pnpm --filter @salesforce/b2c-dx-mcp run test:agent — 720 passing
  • pnpm run lint:agent — clean
  • pnpm run typecheck:agent — clean
  • CI — pending

Resolves High and Medium findings from the test-quality audit. No source code
changes — only test files. Baselines preserved or improved:

  b2c-cli:          1218 → 1224 passing
  b2c-tooling-sdk:  1722 → 1717 passing (0 pending; -13 tautological smokes,
                                          +2 substantive tests, +6 previously
                                          silently-skipped tests now run)
  b2c-dx-mcp:       720  → 720  passing

Highlights:
- Removed mock theater: webdav `buildPath` SUT-stubs, openapi-fetch passthrough
  comparisons, and "client creation" `to.exist` smokes that TypeScript already
  proved.
- SCAPI command tests for "displays/logs in non-JSON mode" now capture stdout
  and assert on rendered content; renderer is no longer stubbed.
- Replication 422/409 errors, sites "no sites" copy, content/validate real-
  validator path, job `--show-log` invocation are now actually verified.
- e2e tests: replaced `oneOf([0,1])` and conditional-assertion patterns with
  deterministic asserts; code-lifecycle delete captures version id before
  clearing; sandbox delete follows up with a `get` 404 check; AM error tests
  match real SUT messages; dead `hasProject` skip gate removed.
- SDK pagination tests either iterate properly or are renamed to match what
  they actually verify; `oauth-jwt`, `auth/middleware`, watcher `stop()`,
  base-command telemetry-skip, and plugin loader tests now assert on
  observable behavior rather than `to.not.throw`.
- `MobifySource` tests use proper DI in place of `Object.defineProperty(os,
  'homedir')` skip-on-fail; logs integration `beforeEach` fails loudly under
  `process.env.CI`.
- MCP `addTool` registration tests intercept `registerTool` and invoke wrapped
  handlers; site-theming filter test verifies the asked question is excluded;
  page-designer-decorator regex tightened to deterministic strings; services
  tests assert OAuth wiring and base URLs.
…ration

The repo's CI does not provision a live B2C instance — the logs integration
suite is genuinely opt-in and skipping is the correct behavior when the
prerequisite is unavailable. Reverts the over-zealous "fail loud under CI"
change introduced earlier in this PR.
Copy link
Copy Markdown
Contributor

@patricksullivansf patricksullivansf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only reviewed mcp changes, but overall looks much better. thanks

Comment thread packages/b2c-dx-mcp/test/tools/scapi/scapi-custom-apis-get-status.test.ts Outdated
Per @patricksullivansf review: the safeParse / isOptional / enum-value
checks were testing Zod itself, not the tool's contract. Keep field-presence
assertion only.
@clavery clavery merged commit 96449da into main May 13, 2026
5 checks passed
@clavery clavery deleted the test/audit-fixup-batch1-7 branch May 13, 2026 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants